import { ResPage } from "@/api/interface/index";
import { SystemUser } from "@/api/interface/systemUser";
import { DRAGON_ADMIN } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 用户管理模块
 */
// 获取用户列表
export const getUserListApi = (params?: SystemUser.UserReq) => {
  return http.get<SystemUser.UserRes[]>(DRAGON_ADMIN + `/api/system/user/list`, params);
};

// 获取用户详情
export const getUserDetailApi = (userId: number) => {
  return http.get<SystemUser.UserDetailRes>(DRAGON_ADMIN + `/api/system/user/detail`, { userId: userId });
};

// 新增角色
export const addUserApi = (params: SystemUser.UserDetailRes) => {
  return http.post<void>(DRAGON_ADMIN + `/api/system/user/add`, params);
};

// 编辑角色
export const editUserApi = (params: SystemUser.UserDetailRes) => {
  return http.put<void>(DRAGON_ADMIN + `/api/system/user/edit`, params);
};

// 删除用户
export const deleteUserApi = (userId: number) => {
  return http.delete<void>(DRAGON_ADMIN + `/api/system/user/delete`, { userId: userId });
};

// 更改用户状态
export const changeUserStatusApi = (params: SystemUser.UserChangeStatusReq) => {
  return http.put<void>(DRAGON_ADMIN + `/api/system/user/changeStatus`, params);
};

// 获取授权角色列表
export const getUserAuthRoleApi = (params: SystemUser.UserAuthRoleReq) => {
  return http.get<ResPage<SystemUser.UserAuthRoleRes[]>>(DRAGON_ADMIN + `/api/system/user/authRoleList`, params);
};

// 批量添加角色授权用户请求参数
export const addUserAuthRoleBatchApi = (params: SystemUser.UserAuthRoleAddBatchReq) => {
  return http.post<void>(DRAGON_ADMIN + `/api/system/user/addAuthRoleBatch`, params);
};
